1. 获取用户信息: AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser());
2. 会员ID: String memberId = currentUser.getId();
3. DDD相互转换: public ${classInfo.className} create${classInfo.className}(${classInfo.className}DTO ${classInfo.className?uncap_first}DTO) {}
4. 创建XXXX预校验:  create${classInfo.className}Check(${classInfo.className?uncap_first}DTO);

5. 获取设置值代码范例
// 查询配置/更新配置 get改为put
http://10.92.131.126:8887/manager/setting/setting/get/BASE_SETTING
accessToken ......

@Autowired
private SettingService settingService;
DiosSetting setting = settingService.get(SettingEnum.ORDER_SETTING.name());
OrderSetting orderSetting = JSONUtil.toBean(setting.getSettingValue(), OrderSetting.class);
或
BaseSetting baseSetting = JSONUtil.toBean(settingService.get(SettingEnum.BASE_SETTING.name()).getSettingValue(), BaseSetting.class);
从具体中取到值.....
Integer minute = orderSetting.getAutoCancel();

6. redisson加锁(简单版)
@Autowired
private RedissonClient redisson;

RLock lock = redisson.getLock(t.getSn());
lock.lock(60, TimeUnit.SECONDS);
try {
    // 执行业务流程
} catch(Exception e) {
    e.printStackTrace();
} finally {
    lock.unlock();
}

7. 远程调用的写法
a.调用方(dios-shop-bff-biz模块)
@Resource
private OrderFeign orderFeign;

orderFeign.updateById(order);

b. Feign端(dios-api-shop模块)
import com.bering.common.core.feign.FeignClientConfig;

@FeignClient(name = "dios-shop-api", contextId = "OrderFeign", configuration = FeignClientConfig.class)
public interface OrderFeign {
    @PostMapping(value = "/dios/order/updateById")
    ResultMessage<Void> updateById(@RequestBody Order order);
}

c. 接收端(dios-shop-api模块)
@RestController
@RequestMapping("/dios/order")
@Api(tags = "订单相关接口")
public class DiosOrderController {
    @ApiOperation(value = "根据id更新订单信息")
    @PostMapping(value = "/updateById")
    public void updateById(@RequestBody Order order) {
        ......
    }
}

8. Object对象转具体对象
import cn.hutool.json.JSONUtil;
PintuanOrderMessage pintuanOrderMessage = JSONUtil.toBean(JSONUtil.parseObj(object), PintuanOrderMessage.class);
Map dataPermissionMap = new Gson().fromJson(token.getProperty(SecurityConstants.DATA_PERMISSION_SQL_MAP).toString(), Map.class);

9. 延时队列(写法1)
a.添加数据
@Autowired
private RedisDelayQueueUtil redisDelayQueueUtil;
redisDelayQueueUtil.addDelayQueue(orderPaymentTimeoutDTO, minute.longValue(), TimeUnit.MINUTES, RedisDelayQueueEnum.ORDER_PAYMENT_TIMEOUT.getCode());

b.从延时队列中获取数据
入口类:
@Slf4j
@Component
public class RedisDelayQueueRunner implements CommandLineRunner {
    @Autowired
    private RedisDelayQueueUtil redisDelayQueueUtil;
    @Autowired
    private ApplicationContext context;
    @Autowired
    private ThreadPoolTaskExecutor poolTask;

    ThreadPoolExecutor executorService = new ThreadPoolExecutor(3, 5, 30, TimeUnit.SECONDS,
    new LinkedBlockingQueue<Runnable>(1000),new ThreadFactoryBuilder().setNameFormat("order-delay-%d").build());

    @Override
    public void run(String... args) throws Exception {
        poolTask.execute(() -> {
            while (true){
                try {
                    RedisDelayQueueEnum[] queueEnums = RedisDelayQueueEnum.values();
                    for (RedisDelayQueueEnum queueEnum : queueEnums) {
                        Object value = redisDelayQueueUtil.getDelayQueue(queueEnum.getCode());
                        if (value != null) {
                            log.info("延迟队列收到消息：{}", JSONUtil.toJsonStr(value));
                            RedisDelayQueueHandler<Object> redisDelayQueueHandle = (RedisDelayQueueHandler<Object>)context.getBean(queueEnum.getBeanId());
                            executorService.execute(() -> {redisDelayQueueHandle.execute(value);});
                        }
                    }
                    TimeUnit.MILLISECONDS.sleep(500);
                } catch (InterruptedException e) {
                    log.error("(Redission延迟队列监测异常中断) {}", e.getMessage());
                }
            }
        });
        log.info("(Redission延迟队列监测启动成功)");
    }
}

c. 仿照 OrderPaymentTimeoutHandler
@Slf4j
@Component
public class OrderPaymentTimeoutHandler implements RedisDelayQueueHandler<OrderPaymentTimeoutDTO> {

    @Override
    public void execute(OrderPaymentTimeoutDTO t) {
    ......
    }
}

10. 延时队列(写法2)
a. 写入延时队列
BroadcastMessage broadcastMessage = new BroadcastMessage(studio.getId(), StudioStatusEnum.START.name());
TimeTriggerMsg timeTriggerMsg = new TimeTriggerMsg(TimeExecuteConstant.BROADCAST_EXECUTOR,
        Long.parseLong(studio.getStartTime()) * 1000L,
        broadcastMessage,
        DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.BROADCAST, studio.getId()),
        rocketmqCustomProperties.getPromotionTopic());

//发送促销活动开始的延时任务
this.timeTrigger.addDelay(timeTriggerMsg);

b. 从延时队列中取数据
TimeTriggerConsumer 入口类

c. 仿照PromotionTimeTriggerExecutor实现
@Slf4j
@Component(TimeExecuteConstant.PROMOTION_EXECUTOR)
public class PromotionTimeTriggerExecutor implements TimeTriggerExecutor {

    @Autowired
    ......

    @Override
    public void execute(Object object) {
            PintuanOrderMessage pintuanOrderMessage = JSONUtil.toBean(JSONUtil.parseObj(object), PintuanOrderMessage.class);
            ......
    }
}

11. GSON将字符串转换为对象或者Map对象
dataPermissionMap = new Gson().fromJson(token.getProperty(SecurityConstants.DATA_PERMISSION_SQL_MAP).toString(), Map.class);